using UnityEngine;
using System.Collections.Generic;

public class EquippedPanel : HUDPanel
{
	public ButtonID buttonUsed;
	public RectTransform scrollContent;
	
	private List<GameObject> buttons = new List<GameObject>();
	
	public override void UpdatePanel(Character _character)
	{
		foreach (GameObject b in buttons)
		{
			PoolManager.Instance.ReturnToPool(b);
		}
		
		buttons.Clear();
		
		GameObject tempButton;
		CharacterInfo info = _character.GetInfo<CharacterInfo>();

		if (!info.HasWeapon())
		{
			tempButton = PoolManager.Instance.GetFromPool(buttonUsed.ToString());
			ScreensManager.Instance.SetParent(tempButton, scrollContent);
			tempButton.GetComponent<ButtonInteractive>().Setup(_character as Player, info.baseWeapon, false, true);
			buttons.Add(tempButton);
		}

		foreach (UseableInfo useable in info.equipped)
		{
			tempButton = PoolManager.Instance.GetFromPool(buttonUsed.ToString());
			ScreensManager.Instance.SetParent(tempButton, scrollContent);
			tempButton.GetComponent<ButtonInteractive>().Setup(_character as Player, useable, true, true);
			buttons.Add(tempButton);
		}
	}
}
